Description:
ONE detects arithmetic expressions that always return one of their operands' value. This message is produced only for expressions that have at least one operand which is not a compile-time constant. The examined operations are described below.
+) operation has no effect when one of the addends is
zero (0).-) operation has no effect when the subtrahend is
zero (0).*) operation has no effect when either the multiplicand or
the multiplier is one (1)./) operation has no effect when the divisor is one
(1).%) operation has no effect when the right operand is
either greater or less than zero, and the absolute value of the left
operand is less than the absolute value of the right operand.
In this case, x mod y = x or
x mod y = -x.Incorrect:
MenuItem = class
private
name:String;
index:integer;
public
procedure Item(n:String; index:integer);
function getPosition():integer;
end;
...
procedure MenuItem.Item(n:String; index:integer);
begin
self.name := name;
self.index := index;
end;
function MenuItem.getPosition():integer;
var base:integer;
begin
base := 0;
result := index + base;
end;
Correct:
MenuItem = class
private
name:String;
index:integer;
public
procedure Item(name:String; index:integer);
function getPosition():integer;
end;
...
procedure MenuItem.Item(name:String; index:integer);
begin
self.name := name;
self.index := index;
end;
function MenuItem.getPosition():integer;
begin
result := index;
end;